package com.jiangyao.service.impl;

import com.jiangyao.dao.ISysLogDao;
import com.jiangyao.model.entity.SysLog;
import com.jiangyao.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 日志表 服务实现类
 * </p>
 *
 * @author yangyongchuan
 * @since 2020-07-19
 */
@Service
public class SysLogServiceImpl extends BaseServiceImpl<ISysLogDao, SysLog> implements SysLogService {

	@Autowired
	private ISysLogDao sysLogDao;

	@Override
	@Async
	public void asyncSaveSysLog(SysLog sysLog) {
		String request = sysLog.getRequest();
		if (request.length() > 5000) {
			request = request.substring(0, 5000);
			sysLog.setRequest(request);
		}
		String response = sysLog.getResponse();
		if (response.length() > 5000) {
			response = response.substring(0, 5000);
			sysLog.setResponse(response);
		}
		sysLogDao.insert(sysLog);
	}

}
